package com.hjb.service.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hjb.service.bank.BankService;
import com.hjb.service.utils.MapUtil;

/**
 * Created by gy on 2017/8/1.
 *银行获取卡bin
 */
@RestController
@RequestMapping("/bank")
public class BankController {
	private Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	private BankService bankService;

	/**
	 * 获取银行code
	 * @param request
	 * @return
	 */
	@PostMapping("/getBankCode")
	@ResponseBody
	public Map<String, Object> getBankCode(HttpServletRequest request){
		Map<String,Object> resMap = new HashMap<String,Object>();
		try {
			resMap = bankService.getBankInfo(Integer.valueOf(request.getParameter("bankBin")));
		} catch (Exception e) {
			log.info("获取银行信息失败：",e);
			resMap.put("result_code", MapUtil.INTF_ERR_CODE);
			resMap.put("result_info", "调用失败");
		}
		return resMap;
	}

}
